/*
  Author: Ionel Crisu - crisuionel@yahoo.com
  support@FlashExtended.com
*/
package com.flashextended.utils.graphics.windows
{
	import flash.events.MouseEvent;
	import flash.text.TextField;
	
	import mx.core.UIComponent;
	import mx.events.EffectEvent;
	import mx.managers.PopUpManager;

/**
 * Custom Alert class
 * will send to callBack true/false
 * true - ok 
 * false -cancel
 */ 
	public class AlertInfoWindow extends GenericInfoWindow
	{
		private var callBack:Function;
		private var decide:Boolean = false;
		
		public function AlertInfoWindow(w:Number, h:Number, callBack:Function, title:String="Info")
		{
			super(w, h, title);
			this.callBack = callBack;
		}
		
		public function removeCancelButton():void
		{
			this.getFooter().removeChild(this.getCancelButton());
		}
		
		private var _slectableTxt:Boolean=false;
		public function set slectableTxt(val:Boolean):void
		{
			_slectableTxt = val;
		}
		public function get slectableTxt():Boolean
		{
			return _slectableTxt;
		}		
		
		public function set infoText(txt:String):void
		{
			this.getContentPane().setStyle("backgroundColor", 0xedf3fc);
			this.setStyle("backgroundColor", 0xedf3fc);
			var tField:TextField = new TextField();
			tField.width = this.getContentPane().width-10;
			tField.height = this.getContentPane().height-10;
			tField.multiline = true;
			tField.wordWrap = true;
			tField.selectable = slectableTxt;
			tField.htmlText = '<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Verdana" SIZE="12" COLOR="#0B333C" LETTERSPACING="0" KERNING="0">'+txt+'</FONT></P></TEXTFORMAT>';
			var ui:UIComponent = new UIComponent();
			ui.width = tField.width;
			ui.height = tField.height;
			tField.x = 5;
			tField.y = 5;
			ui.addChild(tField);
			this.getContentPane().addChild(ui);
		}
		
		override public function okMouseHandler(e:MouseEvent):void
		{
			decide = true;
			cancelMouseHandler();
		}
		override public function closeWindow(e:EffectEvent=null):void
		{
			try{
			callBack(decide);
			}catch(e:Error){};
			PopUpManager.removePopUp(this);
		}
		
	}
}